// import Layout from "@/views/Main/index.vue"
/**
 * 数据列表转树
 * @param {Object} list 要转换的数据集合
 * @param {string} rootValue 初始根节点值
 * @returns 返回树形数据
 */
export function transListToTreeData(list, rootValue) {
  const arr = []
  list.forEach(item => {
    if (item.pid == rootValue) {
      // 找到了匹配的节点，当前节点 id 和当前子节点的 pid 是相等的
      const children = transListToTreeData(list, item.id) // 字节点的子节点
      if (children.length) item.children = children // 将字节点赋值给当前节点
      arr.push(item)
    }
  })
  return arr
}
// 获取页面权限按钮
var buttonList = [];
export const getButtonList = (routePath,routers) => {
    routers.forEach(element => {
        if (routePath&&element.code) {
            let path = routePath.toLowerCase();
            let p = element.code.replace('.vue','').toLowerCase()
            if (element.code && p === path) {
                buttonList = element.children;
                return;
            } else if (element.children) {
                getButtonList(path,element.children);
            }
        }
    });
    return buttonList;
};

